package org.barad.architecture.analyzer.widgets;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JCheckBox;

import org.barad.architecture.analyzer.archpad.ArchPad;
import org.barad.architecture.analyzer.archpad.region.Region;

public class RegionJCheckBox extends JCheckBox {
	public static final long serialVersionUID = 1L;
	private Region region;
	private ArchPad archPad;
	
	public RegionJCheckBox(ArchPad archPad, Region region, String name) {
		super(name);
		this.archPad = archPad;
		this.region = region;
		setSelected(region.isEnabled());
		addActionListener();
	}
	
	private void addActionListener() {
		addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (isSelected()) {
					region.setEnabled(true);
				} else {
					region.setEnabled(false);
				}
				archPad.getCustomizedJGraph().repaint();
			}
		});
	}
}
